package com.wunong.smart.address.application.request;

import com.wunong.smart.address.client.param.UserAddressParam;
import com.wunong.smart.address.client.vo.UserAddressVO;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Objects;

/**
 * 更新用户地址
 *
 * @author create by zealot.zt
 */
@Getter
@Setter
@ToString(callSuper = true)
public class UpdateUserAddressRequest extends BaseUserAddressRequest {

    private UserAddressVO addressVO;

    public static UpdateUserAddressRequest of(UserAddressParam param) {
        UpdateUserAddressRequest request = new UpdateUserAddressRequest();
        request.initBasic(param);
        request.setAddressVO(param.getAddressVO());
        return request;
    }

    @Override
    public Long getUserId() {
        return Objects.isNull(addressVO) ? userId : addressVO.getUserId();
    }

    @Override
    public Long getId() {
        return Objects.isNull(addressVO) ? id : addressVO.getId();
    }

}
